package com.tender.listeners;

import com.tender.entity.OrderInfoEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;
import org.springframework.stereotype.Component;

/**
 * @description: 状态监听
 */
@Slf4j
@Component
@WithStateMachine(name = "orderStateMachine")
public class OrderInfoListener {

    @OnTransition(source = "APPROVE_PENDING", target = "APPROVE_ING")
    public boolean submitTransition(Message message) {
        OrderInfoEntity orderInfo = (OrderInfoEntity) message.getHeaders().get("orderInfo");
        //taskBean.setId(id++);

        return true;
    }

    @OnTransition(source = "APPROVE_ING", target = "APPROVE_FAILED")
    public boolean passLeadTransition(Message message) {
        OrderInfoEntity orderInfo = (OrderInfoEntity) message.getHeaders().get("orderInfo");
        //taskBean.setId(id++);

        return true;
    }


    @OnTransition(source = "APPROVE_ING", target = "APPROVE_SUCCESS")
    public boolean rejectLeadTransition(Message message) {
        OrderInfoEntity orderInfo = (OrderInfoEntity) message.getHeaders().get("orderInfo");
        //taskBean.setId(id++);

        return true;
    }

}
